package net.jarang.study.spring.converter;

import net.jarang.study.spring.annotation.User;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

public class UserValidator implements Validator {

	@Override
	public boolean supports(Class<?> arg0) {
		return false;
	}

	@Override
	public void validate(Object target, Errors errors) {
		User user = (User)target;
		
		if (user.getName() == null) {
			errors.rejectValue("name", "field.required");
		}
	}

}
